# 使用蒙特卡洛算法求P1，要求精确到小数点后6位
import random

def estimate_pi(num_samples):
    count_inside = 0
    for _ in range(num_samples):
        x = random.uniform(0, 1)
        y = random.uniform(0, 1)
        if x**2 + y**2 <= 1:
            count_inside += 1
    return 4 * count_inside / num_samples

num_samples = 1000000  # 生成1000000个随机点来估计π
result = estimate_pi(num_samples)
print(round(result, 6))